﻿package net.hainan.chat;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.scenery.R;
/****
 * 景点信息定位
 * */
public class Spots extends MapActivity {
	/** Called when the activity is first created. */
	private MapController mapController;
	private GeoPoint geoPoint;
	//MapView mapView = null;

	//private final static String TAG = Spots.class.getSimpleName();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.spots);
		MapView mapView = (MapView) findViewById(R.id.mapview);	
		mapView.setClickable(true);// 允许通过触摸拖动地图
		mapView.setBuiltInZoomControls(true);// 当触摸地图时在地图下方会出现缩放按钮
		mapController = mapView.getController();
		 mapView.setSatellite(true);//卫星模式
		/*显示好友位置*/
		if(ChatRoom.select==0)
		{
			try {
				geoPoint = new GeoPoint((int) (ChatRoom.d2.intValue() * 1000000),
						(int) (ChatRoom.d1.intValue() * 1000000));//定位五公祠
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		/* 显示旅游景点位置 */
		if(ChatRoom.select==1)//五公祠
		{
			try {
				geoPoint = new GeoPoint((int) (20.006782 * 1000000),
						(int) (110.360105 * 1000000));//定位五公祠
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==2)//万绿园
		{
			try {
				geoPoint = new GeoPoint((int) (20.0337300 * 1000000),
						(int) (110.3159300*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==3)//火山口
		{
			try {
				geoPoint = new GeoPoint((int) (19.9299200 * 1000000),
						(int) (110.2004100*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==4)//假日海滩
		{
			try {
				geoPoint = new GeoPoint((int) (20.0357266 * 1000000),
						(int) (110.2379513*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==5)//海瑞墓
		{
			try {
				geoPoint = new GeoPoint((int) (20.0056360 * 1000000),
						(int) (110.2955460*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==6)//南天一柱
		{
			try {
				geoPoint = new GeoPoint((int) (18.2887390 * 1000000),
						(int) (109.3556780*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==7)//热带野生动植物园
		{
			try {
				geoPoint = new GeoPoint((int) (19.7714860 * 1000000),
						(int) (110.2544270*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==8)//鹿回头
		{
			try {
				geoPoint = new GeoPoint((int) (18.2074138 * 1000000),
						(int) (109.4845927*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==9)//神州第一泉
		{
			try {
				geoPoint = new GeoPoint((int) (18.3887010 * 1000000),
						(int) (109.7240930*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==10)//蜈支洲岛
		{
			try {
				geoPoint = new GeoPoint((int) (18.2759220 * 1000000),
						(int) (109.7241660*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==11)//月牙湾
		{
			try {
				geoPoint = new GeoPoint((int) (18.2081740 * 1000000),
						(int) (109.7233800*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==12)//亚龙湾
		{
			try {
				geoPoint = new GeoPoint((int) (18.2057550* 1000000),
						(int) (109.6390630*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==13)//大东海
		{
			try {
				geoPoint = new GeoPoint((int) (18.2035960* 1000000),
						(int) (109.5188670*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==14)//西岛
		{
			try {
				geoPoint = new GeoPoint((int) (18.2922300* 1000000),
						(int) (109.3681970*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==15)//博鳌论坛
		{
			try {
				geoPoint = new GeoPoint((int) (19.1391820* 1000000),
						(int) (110.5690730*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==16)//石梅湾
		{
			try {
				geoPoint = new GeoPoint((int) (18.6621320* 1000000),
						(int) (110.2721340*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==17)//太平山瀑布
		{
			try {
				geoPoint = new GeoPoint((int) (18.7915790* 1000000),
						(int) (109.5229220*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==18)//中华民族文化村
		{
			try {
				geoPoint = new GeoPoint((int) (18.7649760* 1000000),
						(int) (109.5307420*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==19)//万泉河
		{
			try {
				geoPoint = new GeoPoint((int) (19.2440850* 1000000),
						(int) (110.4535660*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==20)//五指山大峡谷漂流
		{
			try {
				geoPoint = new GeoPoint((int) (18.8818540* 1000000),
						(int) (109.5939460*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==21)//琼崖公学纪念亭
		{
			try {
				geoPoint = new GeoPoint((int) (18.8780850* 1000000),
						(int) (109.4011310*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==22)//万宁热带雨林
		{
			try {
				geoPoint = new GeoPoint((int) (18.7260870* 1000000),
						(int) (110.2413530*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==23)//冯白驹故居
		{
			try {
				geoPoint = new GeoPoint((int) (19.8438340* 1000000),
						(int) (110.4893420*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==24)//文昌孔庙
		{
			try {
				geoPoint = new GeoPoint((int) (19.6167340* 1000000),
						(int) (110.7532050*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==25)//红色娘子军
		{
			try {
				geoPoint = new GeoPoint((int) (19.2397060* 1000000),
						(int) (110.4657740*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==26)//吊罗山
		{
			try {
				geoPoint = new GeoPoint((int) (18.6597790* 1000000),
						(int) (109.9159680*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==27)//七星岭
		{
			try {
				geoPoint = new GeoPoint((int) (20.0921320* 1000000),
						(int) (110.5870330*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==28)//香水湾
		{
			try {
				geoPoint = new GeoPoint((int) (18.5726170* 1000000),
						(int) (110.1534390*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==29)//玉蟾宫
		{
			try {
				geoPoint = new GeoPoint((int) (19.5522080* 1000000),
						(int) (110.3673530*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==30)//白石岭
		{
			try {
				geoPoint = new GeoPoint((int) (19.0756270* 1000000),
						(int) (108.8421930*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==31)//枫果山瀑布
		{
			try {
				geoPoint = new GeoPoint((int) (18.6741890* 1000000),
						(int) (109.8411630*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==32)//南山寺
		{
			try {
				geoPoint = new GeoPoint((int) (18.2931000* 1000000),
						(int) (109.1872350*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==33)//文笔峰
		{
			try {
				geoPoint = new GeoPoint((int) (19.5540180* 1000000),
						(int) (110.3677410*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==34)//东郊椰林
		{
			try {
				geoPoint = new GeoPoint((int) (19.5286730* 1000000),
						(int) (110.8754950*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		if(ChatRoom.select==35)//天堂森林公园
		{
			try {
				geoPoint = new GeoPoint((int) (18.2491870* 1000000),
						(int) (109.6251920*1000000));
			} catch (Exception e) {
				e.printStackTrace();		
				
			}
		}
		
			MyOverlay myOverlay = new MyOverlay();
			mapView.getOverlays().add(myOverlay);
			mapController.setZoom(19);//按照1:20来显示
			mapController.animateTo(geoPoint);//以动画的方式定位
		}
	
		

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

	class MyOverlay extends Overlay {

		@Override
		public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
				long when) {
			Paint paint = new Paint();
			paint.setColor(Color.RED);
			Point screenPoint = new Point();
			mapView.getProjection().toPixels(geoPoint, screenPoint);
			Bitmap bmp = BitmapFactory.decodeResource(getResources(),
					R.drawable.here);
			canvas.drawBitmap(bmp, screenPoint.x, screenPoint.y, paint);

			if(ChatRoom.select==1)//五公祠
			{
				canvas.drawText("五公祠", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==2)//万绿园
			{
				canvas.drawText("万绿园", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==3)//火山口
			{
				canvas.drawText("火山口", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==4)//假日海滩
			{
				canvas.drawText("假日海滩", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==5)//海瑞墓
			{
				canvas.drawText("海瑞墓", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==6)//南天一柱
			{
				canvas.drawText("南天一柱", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==7)//热带野生动植物
			{
				canvas.drawText("热带野生动植物", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==8)//鹿回头
			{
				canvas.drawText("鹿回头", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==9)//神州第一泉
			{
				canvas.drawText("神州第一泉", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==10)//蜈支洲岛
			{
				canvas.drawText("蜈支洲岛", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==11)//月牙湾
			{
				canvas.drawText("月牙湾", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==12)//亚龙湾
			{
				canvas.drawText("亚龙湾", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==13)//大东海
			{
				canvas.drawText("大东海", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==14)//西岛
			{
				canvas.drawText("西岛", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==15)//博鳌论坛
			{
				canvas.drawText("博鳌论坛", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==16)//石梅湾
			{
				canvas.drawText("石梅湾", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==17)//太平山瀑布
			{
				canvas.drawText("太平山瀑布", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==18)//中华民族文化村
			{
				canvas.drawText("中华民族文化村", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==19)//万泉河
			{
				canvas.drawText("万泉河", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==20)//五指山大峡谷漂流
			{
				canvas.drawText("五指山大峡谷漂流", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==21)//琼崖公学纪念亭
			{
				canvas.drawText("琼崖公学纪念亭", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==22)//热带雨林
			{
				canvas.drawText("热带雨林", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==23)//冯白驹故居
			{
				canvas.drawText("冯白驹故居", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==24)//文昌孔庙
			{
				canvas.drawText("文昌孔庙", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==25)//红色娘子军
			{
				canvas.drawText("红色娘子军", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==26)//吊罗山
			{
				canvas.drawText("吊罗山", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==27)//七星岭
			{
				canvas.drawText("七星岭", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==28)//香水湾
			{
				canvas.drawText("香水湾", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==29)//玉蟾宫
			{
				canvas.drawText("玉蟾宫", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==30)//白石岭
			{
				canvas.drawText("白石岭", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==31)//枫果山瀑布
			{
				canvas.drawText("枫果山瀑布", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==32)//南山寺
			{
				canvas.drawText("南山寺", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==33)//文笔峰
			{
				canvas.drawText("文笔峰", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==34)//东郊椰林
			{
				canvas.drawText("东郊椰林", screenPoint.x, screenPoint.y, paint);
			}
			if(ChatRoom.select==35)//天堂森林公园
			{
				canvas.drawText("天堂森林公园", screenPoint.x, screenPoint.y, paint);
			}
			return super.draw(canvas, mapView, shadow, when);
		}

	}
}